define(["jquery","utils","HeatMapMouseArea","HeatPoint"], function($,utils, HeatMapMouseArea,HeatPoint){
    
    function HeatMapMouseMoveArea(obj) {
        // private stuff
        HeatMapMouseArea.call(this,obj);
    };

    //erste den Prototyepen mit dem Parent überschreiben
    var _super = utils.extend(HeatMapMouseMoveArea,HeatMapMouseArea);

    //anschließend den  Prototypen der Klasse erweitern
    $.extend(HeatMapMouseMoveArea.prototype, {
       
        initInputCaptureAbility :function(){
            var active = false,
            lastCoords = [],
            mouseMove = false,
            mouseOver = false,
            timer = null,
            t = this,
            obj =t.domObj,
            xx = t.heatmap;
            if (utils.stopanalyse) return;
            activate = function(){
                active = true;
            },
            simulateEv = function(){

                t.heatPointList.push(new HeatPoint(lastCoords[0], lastCoords[1]));
                //xx.store.addDataPoint(lastCoords[0], lastCoords[1]);
                },
            antiIdle = function(){
                if(mouseOver && !mouseMove && lastCoords && !timer){
                    timer = setInterval(simulateEv, 1000);          
                }
            };

            (function(fn){
                setInterval(fn, 1000);
            }(antiIdle));

            obj.onmouseout = function(){
                mouseOver = false;
                if(timer){
                    clearInterval(timer)
                    timer = null;
                }
            };
            obj.onmousemove = obj.onclick = function(ev){
                mouseMove = true;
                mouseOver = true;
                if(active){
                    if(timer){
                        clearInterval(timer);
                        timer = null;
                    }
                    var pos = h337.util.mousePosition(ev);
                    var realPos = utils.calcMousePostion(ev.target,this,pos);
                    console.log("Obj: " + this.id + " Pos: " + realPos.x +  " : " +realPos.y);
                    //xx.store.addDataPoint(pos[0], pos[1]);
                    t.heatPointList.push(new HeatPoint(realPos.x,realPos.y));
                    lastCoords = [realPos.x,realPos.y];
                    
                    active = false;
                }
                mouseMove = false;
            };

            obj["ontouchmove"] = function(ev){  
                var touch = ev.touches[0],  
                // simulating a mousemove event           
                simulatedEvent = document.createEvent("MouseEvent");  
                simulatedEvent.initMouseEvent(  "mousemove", true, true, window, 1,  
                                                touch.screenX, touch.screenY,  
                                                touch.clientX, touch.clientY, false,  
                                                false, false, false, 0, null);  
                // dispatching the simulated event              
                touch.target.dispatchEvent(simulatedEvent);  
                // we don't want to have the default iphone scrolling behaviour ontouchmove  
                ev.preventDefault();  
            };  

            (function(fn){
                setInterval(fn, 10);
            }(activate));
        }
    });
    return HeatMapMouseMoveArea;
});